package cn.wangsy.zhidao.p20170120;

import java.util.Calendar;
import java.util.Scanner;

public class SampleOutput {

	public static String []MONTHS = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
	
	public static void main() {
		
		String days[][] = new String[32][14];
		
		// 填充零
		for(int i=0;i<days.length;i++){
			for(int j=0;j<days[i].length;j++){
				days[i][j] = "000";
			}
		}

		//月份信息
		for(int i=0;i<MONTHS.length;i++){
			days[0][i+1] = MONTHS[i];
		}
		
		//首尾两列
		for(int i=0;i<=31;i++){
			days[i][0] = days[i][13] = i==0?"Day":String.valueOf(i);
		}
		
		//填充数据
		Calendar calendar = Calendar.getInstance();
		for(int month = 0;month<=12;month++){
			calendar.set(Calendar.MONTH, month);
			calendar.set(Calendar.DATE, 1);
			
			while(calendar.get(Calendar.MONTH) == month){
				int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
				int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
				days[dayOfMonth][month+1] = String.format("%03d", dayOfYear);
				calendar.add(Calendar.DATE, 1);
			}
			
		}
		
		//打印数组
		for(int i=0;i<days.length;i++){
			for(int j=0;j<days[i].length;j++){
				System.out.print(days[i][j]+"\t");
			}
			System.out.println();
		}
		
	}
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入年份：");
		int year = scanner.nextInt();
		
		String days[][] = new String[32][14];
		
		// 填充零
		for(int i=0;i<days.length;i++){
			for(int j=0;j<days[i].length;j++){
				days[i][j] = "000";
			}
		}

		//月份信息
		for(int i=0;i<MONTHS.length;i++){
			days[0][i+1] = MONTHS[i];
		}
		
		//首尾两列
		for(int i=0;i<=31;i++){
			days[i][0] = days[i][13] = i==0?"Day":String.valueOf(i);
		}
		
		//填充数据
		Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.YEAR, year);
		for(int month = 0;month<=12;month++){
			calendar.set(Calendar.MONTH, month);
			calendar.set(Calendar.DATE, 1);
			
			while(calendar.get(Calendar.MONTH) == month){
				int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
				int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR);
				days[dayOfMonth][month+1] = String.format("%03d", dayOfYear);
				calendar.add(Calendar.DATE, 1);
			}
			
		}
		
		//打印数组
		for(int i=0;i<days.length;i++){
			for(int j=0;j<days[i].length;j++){
				System.out.print(days[i][j]+"\t");
			}
			System.out.println();
		}
		
	}

}
